package main

import "fmt"

func modifyUser(users map[string]map[string]string, name string) {

	// 判断users中是否有name
	if users[name] != nil {

		users[name]["pwd"] = "888888"

	} else {

		// 没有这个用户
		users[name] = make(map[string]string, 2)
		users[name]["pwd"] = "888888"
		users[name]["nickname"] = "nickname" + name

	}

}


func main() {

	var users map[string]map[string]string

	users = make(map[string]map[string]string, 10)

	users["tom"] = make(map[string]string, 2)
	users["tom"]["pwd"] = "99999999"
	users["tom"]["nickname"] = "aa"
	fmt.Println(users)

	modifyUser(users, "tom")
	modifyUser(users, "marry")

	fmt.Println(users)

}